/*
 * @Author: error: git config user.name && git config user.email & please set dead value or install git
 * @Date: 2022-08-16 10:26:50
 * @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
 * @LastEditTime: 2022-08-23 14:32:04
 * @FilePath: \施航4阶段react\src\components\Addacustomer.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Button, Form, Input } from 'antd';
import React from 'react';
import { useNavigate } from 'react-router-dom'
import axios from 'axios';
const AddSuppliers = () => {
    const onFinish = (values) => {
        axios({
            method: "post",
            url: "http://localhost:3000/sys/clientManager/addSupplier",
            headers: {

            }, data: {
                "supplierAddress": values.supplierAddress,
                "supplierContactsName": values.supplierContactsName,
                "supplierContactsTel": values.supplierContactsTel,
                "supplierEmail": values.supplierEmail,
                "supplierFixTel": values.supplierFixTel,
                "supplierId": 0,
                "supplierName": values.supplierName,
                "supplierRemarks": values.supplierRemarks
            }
        }).then((res) => {
            console.log(res);
            clickCityHandle();
        });
    }


    const onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
    };
    const navigate = useNavigate();
    function clickCityHandle() {
        navigate('/home/7/ghcs')
    }

    return (
        <>
            <div className='Lists'>
                <div>添加供货商</div>
                <Button type="primary" onClick={clickCityHandle}>返回</Button>
            </div>
            <div className='addsupply'>
                <div className='addsupplys'>添加供货商</div>
                <Form
                    name="basic"
                    labelCol={{
                        span: 8,
                    }}
                    wrapperCol={{
                        span: 16,
                    }}
                    initialValues={{
                        remember: true,
                    }}
                    onFinish={onFinish}
                    onFinishFailed={onFinishFailed}
                    autoComplete="off"
                >
                    <Form.Item
                        label="厂商名称"
                        name="supplierName"
                        rules={[
                            {
                                required: true,
                                message: '请输入厂商名称',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>
                    <Form.Item
                        label="联系人"
                        name="supplierContactsName"
                        rules={[
                            {
                                required: true,
                                message: '请输入联系人',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>
                    <Form.Item
                        label="手机号码"
                        name="supplierContactsTel"
                        rules={[
                            {
                                required: true,
                                message: '请输入手机号码',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>
                    <Form.Item
                        label="固话"
                        name="supplierFixTel"
                    >
                        <Input />
                    </Form.Item>
                    <Form.Item
                        label="邮箱"
                        name="supplierEmail"
                    >
                        <Input />
                    </Form.Item>
                    <Form.Item
                        label="厂商地址"
                        name="supplierAddress"
                        rules={[
                            {
                                required: true,
                                message: '请输入厂商地址',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="备注"
                        name="supplierRemarks"
                    >
                        <textarea name="" id="" cols="60" rows="5" placeholder='请输入备注'></textarea>
                    </Form.Item>
                    <Form.Item
                        wrapperCol={{
                            offset: 8,
                            span: 16,
                        }}
                    >
                        <Button type="primary" htmlType="submit">
                            提交
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        </>
    );
};
export default AddSuppliers;